﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Entity.Package
{    
    /// <summary>
    /// 包头
    /// </summary>
   
    public class PackHead
    {
        private string packCode = "01";  //包头固定值
        public string PackCode
        {
            get { return packCode; }
            set { packCode = value; }
        }
        private string pointCode = "0009";//缴费点代码
        public string PointCode
        {
            get { return pointCode; }
            set { pointCode = value; }
        }
        private string pointPwd = "     "; //缴费点密码
        public string PointPwd
        {
            get { return pointPwd; }
            set { pointPwd = value; }
        }
        private string reservedField = " "; //预留字段
        public string ReservedField
        {
            get { return reservedField; }
            set { reservedField = value; }
        }
        private string payWay; //缴费方式
        public string PayWay
        {
            get { return payWay; }
            set { payWay = value; }
        }
        private string bankWaterNumber; //银行流水号
        public string BankWaterNumber
        {
            get { return bankWaterNumber; }
            set { bankWaterNumber = value; }
        }

        private string packLength;//包体长度
        public string PackLength
        {
            get { return packLength; }
            set { packLength = value; }
        }

        public PackHead()
        { }

        //构造函数
        public PackHead(string valuePayWay, string valueBankWaterNumber,string valuePackLength)
        {
            this.payWay = valuePayWay;
            this.bankWaterNumber = valueBankWaterNumber;
            this.packLength = valuePackLength;
        }

        public override string ToString()
        {
            return packCode.PadLeft(2,'0')+pointCode.PadLeft(4,'0')+pointPwd.PadRight(5,' ')
                   +reservedField.PadRight(1,' ')+payWay.PadLeft(2, '0')+
                   bankWaterNumber.PadRight(14, ' ')+packLength.PadLeft(4, '0')+"|";
        } 
    }

    public class PackFailReturn
    {
        //通用结构        
        private PackHead packHead;
        public PackHead PackHead
        {
            get { return packHead; }
            set { packHead = value; }
        }
        private string tradeCode = "";   //交易码
        public string TradeCode
        {
            get { return tradeCode; }
            set { tradeCode = value; }
        }
        private string responseCode = ""; //响应码
        public string ResponseCode
        {
            get { return responseCode; }
            set { responseCode = value; }
        }

        public override string ToString()
        {
            string packBody = tradeCode + "|" + responseCode;
            if (packHead == null)
                return packBody;
            else
                return packHead.ToString() + packBody;
        }
    }
}